window.onload = function() {
	seajs.use(['jquery-1.8.2.js', 'iscroll_module.js', 'mdialog_module.js', 'util_module.js'], function(Z, I, M, U) {
		var user = U.checkLogin();
		U.fillHead();
		U.fillFooter();
		initPage();
		function initPage() { //初始化页面
			U.loadOpt(false);
				/*if(user.state != 1) {
						alert("请先登录!");
						U.loadLogin(true);
					} else {
						if(user.info.personVO.status == 1) {
							//alert("您的资料还在审核中!");
							location.href = "wait_review.html";
							return false;
						} else if(user.info.personVO.status == 0) {
							
						}
					}*/
			initEvent();
		}
		function initEvent() {
			//申请成为帮扶人员
			$(".applyHelp").click(function(){
				if(user.state != 1) {
					alert("请先登录!");
					U.loadLogin(true);
					return;
				}
				if(user.info.typ==0 ){
					//location.href="personal_apply_edit.html?index=1";
					//attention.html
					location.href="attention.html";
				}
				else if(user.info.typ==4){
					location.href="wait_review.html?index=1";
				}
				else{
					alert("不能申请成为帮扶人员!");
				}

			});
			
		/*	$('.btn .tuandui a').click(function(){
				location.href='team_apply_edit.html';
			});
			
			$('.btn .qiye span').click(function(){
				location.href='firm_apply_edit.html';
			});*/
			//申请成为贫困户
			$(".applyPoor").click(function(){


				$("body").append("<div class='sain' style='width: 100%;height: 100%;position:fixed;top:0;left:0;bottom:0;right:0;background-color:#000;opacity: 0.5;display: block'></div><div id='confirm' style='width: 460px;height: 300px;position: fixed;top: 30%;left: 37.5%;z-index: 21;' ><div  style='width: 100%;height: 60px;;text-align: center;background-color: #EFEFEF;font-size: 18px;line-height: 60px;'>提示</div><div style='width: 100%;height: 240px;background-color: #ffffff;' ><span style='font-size: 16px;color: #333333;line-height: 30px;padding: 39px 70px;display: block;'>本捐款用于未进入结对帮扶的城乡因病、因灾、因学返贫致贫的特困户，可通过网上申请或在当地民政部门申请。</span><div><span class='confirm-no' style='display: block;margin-top: 30px;width: 100px;height: 40px;border-radius: 5px;line-height: 40px;text-align: center;color: #333333;font-size: 20px;margin: 0 auto;background-color: rgb(239, 239, 239);cursor: pointer;float: left;margin-left: 20%'>取消</span><span class='confirm-OK' style='display: block;margin-top: 30px;width: 100px;height: 40px;border-radius: 5px;line-height: 40px;text-align: center;color: #ffffff;font-size: 20px;margin: 0 auto;background-color: #D30C1A;cursor: pointer;float:left;margin-left: 50px'>完成</span></div></div></div>");
				$(".sain").css("display","block");
				$("#confirm").css("display","block");
				$("#confirm>div").css("display","block");

				$(".confirm-OK").click(function(){
					$("#confirm").remove();
					$(".sain").remove();
					if(user.state != 1) {
						alert("请先登录!");
						U.loadLogin(true);
						return;
					}
					if(user.info.typ==0 ){
						location.href='poor_people_edit.html?index=2';
					}
					else if(user.info.typ==3){
						location.href='user_poor_people_info.html?index=2';
					}
					else{
						alert("不能申请成为贫困户!");
					}
				})
				$(".confirm-no").click(function(){
					$("#confirm").remove();
					$(".sain").remove();
				})

			});

		}
	});
};